$(function () {
    // 导航 依赖element模块,否则无法进行功能性操作
    layui.use('element',function(){
        var element = layui.element;
    });

    // 表单,依赖 form 模块
    layui.use('form', function() {
        var form = layui.form;
    })
    

    $("#get_out").click(function (){
        localStorage.removeItem("token")
        layer.msg("退出成功",{icon:6});
    })

    $("#login").click(function (){
        var token = localStorage.getItem('token');
            $.ajax({
                url:"test",
                headers:{
                    //bearer后面必须要有空格，并且bearer大小写有区别，需与后台验证保持一致
                    "Authorization": "Bearer "+token
                },
                dataType:"json",
                type:"post",
                success:function (result) {
                    if (result.code==200){
                        layer.msg("您已经登录",{icon: 6,time:2000})
                    }if (result.code!=200){
                        window.location.href="http://localhost:9090/godance/login.html";
                    }
                }
            })
    })
})